﻿<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script src="~/Scripts/jquery-1.9.1.min.js"></script>
    <style type="text/css">
        .pl1 {
        float:left;
        margin:inherit;
        }
        .tatol {
        font-size:40px;
        background-color:aquamarine;
        font-family:"宋体";
         width:auto;
         height:auto;
        }
        .sq1 {
            text-align:center;  
            height:25px;
            line-height:25px;
            width:auto;
      border:1px solid #000000
        }
        .tr1 {
        height:35px;
        width:auto;
        }
    </style>
    <script type="text/javascript">
        //$(function () {
        //    var pars = $("#Indent2").val();
        //})
        $(function () {
            loadData();
            $("#BtnQuery").click(function () {
                debugger;
                var pars = $("#Indent2").val();
                loadData(pars);
            });
        });
 
        function loadData(pars) {
            $.ajax({
                type: "post",
                url: "/MyAdmin/check",
                data: {
                    pars
                    },
                cache: false,
                async: false,
                success: function (data) {
                    debugger;
                    var str = "";
                    var s = Math.floor(data.para.length / 10);//获取总页数
                    ++s;
                    var str1 ='总页数：'+s;
                    $("#ps").html(str1);
                    var ssss = 1;
                    $("#text1").val(ssss);
                    if (pars != "" && pars!=null) {
                        for (var i = 0; i < data.para.length; i++) {
                            str += ' <tr class="tr1">';
                            str += '      <td>' + data.para[i].id + '</td>      ';
                            str += '      <td>' + data.para[i].order1 + '</td>        ';
                            str += '      <td>' + data.para[i].indentTimeList + '</td> ';
                            str += '      <td>' + data.para[i].addressName + '</td>     ';
                            str += '      <td>' + data.para[i].addressShouHuo + '</td>       ';
                            str += '      <td>' + data.para[i].phone + '</td>     ';
                            str += '      <td>' + data.para[i].zong + '</td>        ';
                            str += '  </tr>      ';
                        }
                        $("#aaa").html(str);
                    }//有条件查询
                    var sss1=((--ssss) * 10);
                    for (var i = 0 + sss1 ; i < sss1 + 10; i++) {//将后台传过来的值赋进table
                        str += ' <tr class="tr1">';
                        str += '      <td>' + data.para[i].id + '</td>      ';
                        str += '      <td>' + data.para[i].order1 + '</td>        ';
                        str += '      <td>' + data.para[i].indentTimeList + '</td> ';
                        str += '      <td>' + data.para[i].addressName + '</td>     ';
                        str += '      <td>' + data.para[i].addressShouHuo + '</td>       ';
                        str += '      <td>' + data.para[i].phone + '</td>     ';
                        str += '      <td>' + data.para[i].zong + '</td>        ';
                        str += '  </tr>                   ';
                    }
                    $("#aaa").html(str);

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    alert("请求失败！");
                }
            });
        }//页面加载
        function TopPage() {
            $.ajax({
                type: "post",
                url: "/MyAdmin/check",
                cache: false,
                async: false,
                success: function (data) {
                    debugger;
                    var str = "";
                    var s = Math.floor(data.para.length / 10);//获取总页数
                    ++s;
                    var str1 = '总页数：' + s;
                    $("#ps").html(str1);//写总页数进网页
                    var sss2 = $("#text1").val();//取当前页数
                    if (sss2==1) {
                        alert("已经是第一页了");
                        return;
                    }
                    --sss2;//第一次减减显示查询后页数
                    $("#text1").val(sss2);
                    --sss2;//第二次减减用来查询页面数据
                    var sss1 = ((sss2) * 10);//以10条数据分页
                    for (var i = 0 + sss1 ; i < sss1 + 10; i++) {//将后台传过来的值赋进table
                        str += ' <tr class="tr1">';
                        str += '      <td>' + data.para[i].id + '</td>      ';
                        str += '      <td>' + data.para[i].order1 + '</td>        ';
                        str += '      <td>' + data.para[i].indentTimeList + '</td> ';
                        str += '      <td>' + data.para[i].addressName + '</td>     ';
                        str += '      <td>' + data.para[i].addressShouHuo + '</td>       ';
                        str += '      <td>' + data.para[i].phone + '</td>     ';
                        str += '      <td>' + data.para[i].zong + '</td>        ';
                        str += '  </tr>                   ';
                    }
                    $("#aaa").html(str);

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    alert("请求失败！");
                }
            });
        }//上一页
        function BottomPage() {
            $.ajax({
                type: "post",
                url: "/MyAdmin/check",
                cache: false,
                async: false,
                success: function (data) {
                    debugger;
                    var str = "";
                    var s = Math.floor(data.para.length / 10);//获取总页数
                    ++s;
                    var str1 = '总页数：' + s;
                    $("#ps").html(str1);//写总页数进网页
                    var sss2 = $("#text1").val();//取当前页数
                    if (sss2 == s) {
                        alert("已经是最后一页了");
                        return;
                    }
                    var sss4 = (sss2*1)+ 1;//加一显示下一页页数
                    $("#text1").val(sss4);
                    var sss1 = ((sss2) * 10);//以10条数据分页
                    var sss3 = data.para.length - sss1   //判断减去前面的条数后还剩几条数据
                    if (sss3 < 10) {
                        for (var i = 0 + sss1 ; i < sss1+sss3; i++) {//将后台传过来的值赋进table
                            str += ' <tr class="tr1">';
                            str += '      <td>' + data.para[i].id + '</td>      ';
                            str += '      <td>' + data.para[i].order1 + '</td>        ';
                            str += '      <td>' + data.para[i].indentTimeList + '</td> ';
                            str += '      <td>' + data.para[i].addressName + '</td>     ';
                            str += '      <td>' + data.para[i].addressShouHuo + '</td>       ';
                            str += '      <td>' + data.para[i].phone + '</td>     ';
                            str += '      <td>' + data.para[i].zong + '</td>        ';
                            str += '  </tr>                   ';
                        }
                        $("#aaa").html(str);
                        return;
                    }
                    for (var i = 0 + sss1 ; i < sss1 + 10; i++) {//将后台传过来的值赋进table
                        str += ' <tr class="tr1">';
                        str += '      <td>' + data.para[i].id + '</td>      ';
                        str += '      <td>' + data.para[i].order1 + '</td>        ';
                        str += '      <td>' + data.para[i].indentTimeList + '</td> ';
                        str += '      <td>' + data.para[i].addressName + '</td>     ';
                        str += '      <td>' + data.para[i].addressShouHuo + '</td>       ';
                        str += '      <td>' + data.para[i].phone + '</td>     ';
                        str += '      <td>' + data.para[i].zong + '</td>        ';
                        str += '  </tr>                   ';
                    }
                    $("#aaa").html(str);

                },
                error: function (XMLHttpRequest, textStatus, errorThrown) {
                    alert("请求失败！");
                }
            });
        }//下一页
    </script>
</head>
<body style="margin:0px;">
    <div align="center">
        <div   style="padding-top: 20px;height:50px;background-color:darkturquoise">
            订单号：<input type="text" id="Indent2" class="Indent1" />
            <input type="button" value="查询" id="BtnQuery"/>
        </div>
        <div>
            <table id="data1" style="margin:0px; width:100%;height:auto;text-align:center" border="1" cellspacing="0">
                <thead class="tatol">
                    <tr>
                        <th>订单号</th>
                        <th>用户名</th>
                        <th>订单时间</th>
                        <th>收货姓名</th>
                        <th>收货地址</th>
                        <th>联系电话</th>
                        <th>总金额</th>
                    </tr>
                </thead>
                <tbody id="aaa">
                    <tr class="tr1"></tr>
                    <tr class="tr1"></tr>
                    <tr class="tr1"></tr>
                    <tr class="tr1"></tr>
                    <tr class="tr1"></tr>
                    <tr class="tr1"></tr>
                </tbody>
            </table>
        </div>
        <div  class="sq1">
            <p class="pl1">首页</p>
            <p class="pl1">/</p>
            <p class="pl1">尾页</p>
            <p class="pl1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p> 
            <p class="pl1" onclick="TopPage()">上一页</p>
            <input id="text1" class="pl1" style="width:30px;height:auto;line-height:initial;text-align:center;margin-top: 2px;" type="text" value="1"  />
            <p class="pl1"  onclick="BottomPage()">下一页</p>
            <p class="pl1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p> 
            <p id="ps"  class="pl1"></p>
        </div>
    </div>
</body>
</html>
